import Vue from 'vue'
import Router from 'vue-router'
import Come from '@/components/come'
import Welcome from '@/components/welcome'
import Navbar from '@/components/navbar'
import Trademark from '@/components/trademark'
import Xcx from '@/components/xcx'
import Transit from '@/components/transit'
import Detail from '@/components/detail'
import News from '@/components/news'
import RedPocket from '@/components/redPocket'
import Regs from '@/components/regs'
import Logins from '@/components/logins'
import Move from '@/components/move'
import Center from '@/components/person/center'
import Withdraw from '@/components/person/withdraw'
import Noalipay from '@/components/person/noalipay'
import Edit from '@/components/person/edit'
import Bind from '@/components/person/bind'
import Team from '@/components/person/team'
import SearchMember from '@/components/person/searchMember'
import Collect from '@/components/person/collect'
import Order from '@/components/person/order'
import OrderMore from '@/components/person/orderMore'
import Lately from '@/components/person/lately'
import Care from '@/components/person/care'
import Print from '@/components/person/print'
import Bill from '@/components/person/bill'
import Login from '@/components/person/login'
import Reg from '@/components/person/reg'
import Agreement from '@/components/person/agreement'
import Privacy from '@/components/person/privacy'
import Teamwork from '@/components/person/teamwork'
import Note from '@/components/person/note'
import Forget from '@/components/person/forget'
import Set from '@/components/person/set'
import Reset from '@/components/person/reset'
import Yard from '@/components/person/yard'
import Invite from '@/components/person/invite'
import Statistics from '@/components/person/statistics'
import StatisticsNew from '@/components/person/statisticsNew'
import RetailList from '@/components/person/retailList'
import Chart from '@/components/person/chart'
import Chartd from '@/components/person/chartd'
import appDownload from '@/components/appDownload'


Vue.use(Router)

export default new Router({
  routes: [
    {
      path: '/',
      name: 'Home',
      component: resolve => require(['@/components/Home'], resolve),
      meta: {
        isUseCache: false,
        keepAlive: true  // 通过此字段判断是否需要缓存当前组件  
      }
    },
    {
      path: '/appDownload',
      name: 'appDownload?num='+new Date().getTime(),
      component: appDownload
    },
    {
      path: '/come',
      name: 'Come',
      component: Come
    },
    {
      path: '/xcx',
      name: 'Xcx',
      component: Xcx
    },
    {
      path: '/statistics',
      name: 'Statistics',
      component: Statistics
    },
    {
      path: '/statisticsNew',
      name: 'statisticsNew',
      component: StatisticsNew,
      meta: {
        isUseCache: false,
        keepAlive: true  // 通过此字段判断是否需要缓存当前组件  
      }
    },
    {
      path: '/chart',
      name: 'chart',
      component: Chart,
    },
    {
      path: '/chartd',
      name: 'chartd',
      component: Chartd,
    },
    {
      path: '/retailList',
      name: 'retailList',
      component: RetailList,
    },
    // {
    //   path: '/welcome',
    //   name: 'Welcome',
    //   component: Welcome
    // },      
    {
      path: '/choose',
      name: 'Choose',
      component: resolve => require(['@/components/choose'], resolve),
      meta: {
        isUseCache: false,
        keepAlive: true  // 通过此字段判断是否需要缓存当前组件  
      }
    },
    {
      path: '/navbar',
      name: 'Navbar',
      component: Navbar
    },
    {
      path: '/trademark',
      name: 'Trademark',
      component: Trademark
    },
    {
      path: '/transit',
      name: 'Transit',
      component: Transit
    },
    {
      path: '/possess',
      name: 'Possess',
      component: resolve => require(['@/components/possess'], resolve),
      meta: {
        isUseCache: false,
        keepAlive: true  // 通过此字段判断是否需要缓存当前组件  
      }
    },
    {
      path: '/seckill',
      name: 'Seckill',
      component: resolve => require(['@/components/seckill'], resolve),
      meta: {
        isUseCache: false,
        keepAlive: true  // 通过此字段判断是否需要缓存当前组件  
      }
    },
    {
      path: '/detail',
      name: 'Detail',
      component: Detail,
    },
    {
      path: '/news',
      name: 'News',
      component: News
    },
    {
      path: '/activity',
      name: 'Activity',
      component: resolve => require(['@/components/activity'], resolve),
      meta: {
        isUseCache: false,
        keepAlive: true  // 通过此字段判断是否需要缓存当前组件  
      }
    },
    {
      path: '/move',
      name: 'Move',
      component: Move
    },
    {
      path: '/list',
      name: 'List',
      component: resolve => require(['@/components/list'], resolve),
      meta: {
        isUseCache: false,
        keepAlive: true  // 通过此字段判断是否需要缓存当前组件  
      }
    },
    {
      path: '/regs',
      name: 'Regs',
      component: Regs
    },
    {
      path: '/logins',
      name: 'Logins',
      component: Logins
    },
    {
      path: '/listing',
      name: 'Listing',
      component: resolve => require(['@/components/listing'], resolve),
      meta: {
        isUseCache: false,
        keepAlive: true  // 通过此字段判断是否需要缓存当前组件  
      }
    },
    {
      path: '/redPocket',
      name: 'RedPocket',
      component: RedPocket
    },
    {
      path: '/center',
      name: 'Center',
      component: Center
    },
    {
      path: '/withdraw',
      name: 'Withdraw',
      component: Withdraw
    },
    {
      path: '/noalipay',
      name: 'Noalipay',
      component: Noalipay
    },
    {
      path: '/edit',
      name: 'Edit',
      component: Edit
    },
    {
      path: '/bind',
      name: 'Bind',
      component: Bind
    },
    {
      path: '/team',
      name: 'Team',
      component: Team
    },
    {
      path: '/searchMember',
      name: 'SearchMember',
      component: SearchMember
    },
    {
      path: '/collect',
      name: 'Collect',
      component: Collect
    },
    {
      path: '/order',
      name: 'Order',
      component: Order
    },
    {
      path: '/orderMore',
      name: 'OrderMore',
      component: OrderMore
    },
    {
      path: '/lately',
      name: 'Lately',
      component: Lately
    },
    {
      path: '/care',
      name: 'Care',
      component: Care
    },
    {
      path: '/print',
      name: 'Print',
      component: Print
    },
    {
      path: '/bill',
      name: 'Bill',
      component: Bill
    },
    {
      path: '/login',
      name: 'Login',
      component: Login
    },
    {
      path: '/reg',
      name: 'Reg',
      component: Reg
    },
    {
      path: '/agreement',
      name: 'Agreement',
      component: Agreement
    },
    {
      path: '/privacy',
      name: 'Privacy',
      component: Privacy
    },
    {
      path: '/teamwork',
      name: 'Teamwork',
      component: Teamwork
    },
    {
      path: '/note',
      name: 'Note',
      component: Note
    },
    {
      path: '/forget',
      name: 'Forget',
      component: Forget
    },
    {
      path: '/set',
      name: 'Set',
      component: Set
    },
    {
      path: '/reset',
      name: 'Reset',
      component: Reset
    },
    {
      path: '/yard',
      name: 'Yard',
      component: Yard
    },
    {
      path: '/invite',
      name: 'Invite',
      component: Invite
    },
  ],
  scrollBehavior(to, from, savedPosition) {
    if (savedPosition) {
      return savedPosition
    } else {
      if (from.meta.keepAlive) {
        from.meta.savedPosition = document.body.scrollTop;
      }
      return { x: 0, y: to.meta.savedPosition || 0 }
    }
  }
})
